﻿using System;
using System.Collections.Generic;
using System.Linq;
using Coffee_Restaurant.Database;

namespace Coffee_Restaurant.DAL
{
    public class AreaDa
    {
        public int DeleteArea(int id)
        {
            try
            {
                using (var db = new DatabaseEntities())
                {
                    var model = db.Areas.Find(id);
                    if (model != null)
                    {
                        db.Areas.Remove(model);
                        return db.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {

                return 0;
            }
            return 0;
        }

        public static List<sp_AreasDataSoure_Result> ListAreas()
        {
            using (var db = new DatabaseEntities())
            {
                var model = db.sp_AreasDataSoure().OrderByDescending(x => x.AreaId).ToList();
                return model;
            }
        }
    }
}
